﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;

namespace Commands
{
    public class AddInitialStateCommand : IUMLCommand
    {
        public const string DefaultCommandTitle = "Add Initial State";

        //Surface to work on
        public IUMLCanvas Surface { get; set; }

        //element to add
        public UIElement Element { get; set; }

        //Title of command
        public string Title { get; set; }

        //Constructor
        public AddInitialStateCommand(IUMLCanvas surface, UIElement element) : this(surface, element, null) { }

        //Constructor
        public AddInitialStateCommand(IUMLCanvas surface, UIElement element, string title)
        {
            if (surface == null) throw new ArgumentNullException("surface");
            if (element == null) throw new ArgumentNullException("element");

            Surface = surface;
            Element = element;
            Title = (!string.IsNullOrEmpty(title)) ? title : DefaultCommandTitle;
        }

        //Fire command
        public void Execute()
        {
            //Add element to surface
            Surface.AddElement(Element);
        }

        //Fire undo
        public void Undo()
        {
            //Remove element from surface
            Surface.RemoveElement(Element);    
        }

        //Fire redo
        public void Redo()
        {
            //Add element to surface
            Surface.AddElement(Element);
        }
    }
}
